
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"/>
    <meta name="keywords" content=""/>
    <meta name="description" content=""/>
    <title>修改小区信息</title>
    <link rel="stylesheet" href="../layui/css/layui.css"/>
    <link rel="stylesheet" href="../css/admin.css"/>
    <style>
        .layui-form{
            /*  width: 350px; */
            height:280px;
            margin:0 auto;
        }
        #btn-c,#btn-s{
            margin-top:20px;
            border:0;
            width: 80px;
            height: 28px;
            border-radius:5px;
            background-color: #D8D8D8;
        }
        #btn-c{
            margin-left:54px;
        }
        #btn-s:hover,#btn-c:hover{
            color:#fff;
            background-color:#EF7632;
        }
        #btn-s{
            margin-left:3px;
        }
        .layui-form select{
            margin-top:20px;
        }
        .layui-btn, .layui-tree li i, .layui-unselect{
            width:fit-content;
        }
        .layui-input{
            border:1px solid #E5BA70;
            margin-top:10px;
            border-radius:5px;
            margin-left:64px;
            width:145px;
        }
        .layui-form-select .layui-input{
            padding-right:2px;
        }
        .layui-form-select dl{
            min-width:68%;
            margin-left:72px;
        }
        .layui-input, .layui-textarea{
            padding-left:10px;
        }
        .layui-form-select dl dd.layui-this{
            color:#2C273D;
            background-color:#fff;
        }
        .add-d{
            width:140px;
            height:34px;
            margin-top:10px;
            margin-left:65px;
            border-radius:5px;
            border:1px solid #E5BA70;
        }
    </style>
</head>
<body>
<form class="layui-form" action="">
    <!-- 省市选择模块 -->
<!--
    <select  id="province" name="province" lay-verify="required"  lay-filter="test">
        <option value="">请选择省份</option>
    </select>
    <select id="city" name="city" lay-verify="required" lay-filter="test1">
        <option value="">请选择城市</option>
    </select>
    <select id="district" name="district"  lay-verify="required" lay-filter="test2">
        <option value="">请选择区/县</option>
    </select>

    <input class="add-d" id="buli_name" type="text" placeholder="请输入小区..." onfocus="this.style.color='#2C273D';
    this.value='';"  onblur="this.style.color='#2C273D';" > <br/>
-->

<!--    <input class="add-d" id="zhuang_num" type="text" placeholder="请输入小区幢数..." onfocus="this.style.color='#2C273D';
    this.value='';"  onblur="this.style.color='#2C273D';" >-->
    <select id="tax_MS" name="district"  lay-verify="required" lay-filter="test3">
        <option value="">选择小区类型</option>
        <option value="0" selected="">商务楼</option>
        <option value="1" selected="">住宅楼</option>
    </select>
    <select id="tax_S" name="district"  lay-verify="required" lay-filter="test7">
        <option value="">乘坐类型</option>
        <option value="0" selected="">开放指定楼层</option>
        <option value="1" selected="">全开放</option>
    </select>
    <select id="tax_M" name="district"  lay-verify="required" lay-filter="test4">
        <option value="">乘坐是否收费</option>
        <option value="0" selected="">免费乘坐</option>
        <option value="1" selected="">收费乘坐</option>
    </select>
    <input class="add-d" id="tax_MY" type="text" placeholder="单次乘坐额度" onfocus="this.style.color='#2C273D';
    this.value='';"  onblur="this.style.color='#2C273D';" >

    <select id="name_M" name="district"  lay-verify="required" lay-filter="test5">
        <option value="">注册是否收费</option>
        <option value="0" selected="">免费注册</option>
        <option value="1" selected="">收费注册</option>
    </select>
    <input class="add-d" id="name_MM" type="text" placeholder="注册收费标注" onfocus="this.style.color='#2C273D';
    this.value='';"  onblur="this.style.color='#2C273D';" > <br/>
    <select id="name_ck" name="district"  lay-verify="required" lay-filter="test6">
        <option value="">注册是否审核</option>
        <option value="0" selected="">无需审核</option>
        <option value="1" selected="">需要审核</option>
    </select>

    <input class="add-d" id="tax_free" type="text" placeholder="免费乘坐次数" onfocus="this.style.color='#2C273D';
    this.value='';"  onblur="this.style.color='#2C273D';" >

    <input type="button" id="btn-c" value="取消">
    <input type="button" id="btn-s" value="保存">
</form>
<script type="text/javascript" src="../layui/layui.js"></script>
<script>

    layui.use(['jquery','form','upload','layer'],function(){

        var layer = layui.layer;
        var $ = layui.jquery;
        var form = layui.form();

        var user_id = window.localStorage.getItem("user_id");
        console.log(user_id );

        var wuyeId = user_id;
        console.log(wuyeId);

        var params = {};

        //新增 下拉获取值
        form.on('select(test3)',function(data){
            var styleValue = data.value;
            var styleName = data.elem[data.elem.selectedIndex].text;
            params.styleValue = styleValue;
            params.styleName = styleName;
            console.log('params.styleValue',params.styleValue);
            console.log('params.styleName',params.styleName);
        })
        form.on('select(test4)',function(data){
            var chengValue = data.value;
            var chengName = data.elem[data.elem.selectedIndex].text;
            params.chengValue = chengValue;
            params.chengName = chengName;
            console.log('params.chengValue',params.chengValue);
            console.log('params.Name',params.chengName);
        });

        form.on('select(test5)',function(data){
            var shouValue = data.value;
            var shouName = data.elem[data.elem.selectedIndex].text;
            params.shouValue = shouValue;
            params.shouName = shouName;
            console.log('params.shouValue',params.shouValue);
            console.log('params.shouName',params.shouName);
        })
        form.on('select(test6)',function(data){
            var shenValue = data.value;
            var shenName = data.elem[data.elem.selectedIndex].text;
            params.is_check = shenValue;
            params.shenName = shenName;
            console.log('params.is_check',params.is_check);
            console.log('params.shenName',params.shenName);
        })
        form.on('select(test7)',function(data){
            var styleValue = data.value;
            var styleName = data.elem[data.elem.selectedIndex].text;
            params.chengti_type = styleValue;
            params.styleName = styleName;
            console.log('params.chengti_type',params.chengti_type);
            console.log('params.styleName',params.styleName);
        })

        $("#btn-s").click(function(){

            var buildingId = localStorage.getItem("buildingId");
            console.log(buildingId );

            var buildingName = localStorage.getItem("buildingName");
            console.log(buildingName );

            var price = $("#tax_MY").val();
            console.log(price);

            var Free_time = $("#tax_free").val();
            params.Free_time = Free_time;
            console.log('params.Free_time',params.Free_time);

            if(params.chengValue == 1){
                params.price = price;
                console.log('params.price',params.price);
            }else if(params.chengValue == 0){
                params.price = 0;
            }else{
                alert("请选择乘坐类型")
            };

            var reg_charge = $("#name_MM").val();
            console.log(reg_charge);

            if(params.shouValue == 1){
                params.reg_charge = reg_charge;
                console.log('params.reg_charge',params.reg_charge);
            }else if(params.shouValue == 0){
                params.reg_charge = 0;
            }else{
                alert("请先选择是否收费")
            };

            $.ajax({
                url: "../../organization_manage/alterBuilding",
                type: "post",
                data: {
                    building_name:buildingName,
                    building_id:buildingId,
                    price:params.price,
                    reg_charge:params.reg_charge,
                    is_check:params.is_check,
                    building_type:params.styleValue,
                    chengti_type:params.chengti_type,
                    reg_gift:params.Free_time
                },
                success: function(response){
                    var response = JSON.parse(response);
                    console.log(response);
                    alert("修改信息成功！");
                    window.parent.location.reload();
                    var index=parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);

                    if(response.resultCode == '200'){

                    }
                },
                error:function(response){
                    console.log(response);
                    alert("修改信息失败！");
                    window.parent.location.reload();
                    var index=parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                    if(response.resultCode=='001'){
                        console.log("param is not found")
                    }
                }
            })
        })//保存
        $("#btn-c").click(function(){
            window.parent.location.reload();
            var index=parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
        })
    });//模块加载
</script>
</body>
</html>
